package com.streamer.app.utils

import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.view.View
import android.view.animation.OvershootInterpolator

object Utils {
    fun playLikeAnimation(target: View) {
        val scaleUpX = ObjectAnimator.ofFloat(target, View.SCALE_X, 1f, 1.35f)
        val scaleUpY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 1f, 1.35f)
        val scaleDownX = ObjectAnimator.ofFloat(target, View.SCALE_X, 1.35f, 1f)
        val scaleDownY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 1.35f, 1f)
        val set = AnimatorSet()
        set.play(scaleUpX).with(scaleUpY)
        set.play(scaleDownX).with(scaleDownY).after(scaleUpX)
        set.duration = 180
        set.interpolator = OvershootInterpolator(2f)
        set.start()
    }
     fun formatTime(ms: Int): String {
        val totalSec = ms / 1000
        val m = totalSec / 60
        val s = totalSec % 60
        return String.format("%02d:%02d", m, s)
    }
}